package com.huawei.appgallery.foundation.store.bean.spilt;

import android.content.Context;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.huawei.appgallery.foundation.store.bean.spilt.DeviceSpec.e;
import com.huawei.appgallery.jsonkit.api.JsonBean;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import o.bks;
import o.bla;
import o.cge;
import o.cgm;
import o.Logger;

public class GetApksInfoRequest extends cgm {
    public static final String APIMETHOD = "client.getApksInfo";
    private static final String TAG = "GetApksInfoRequest";
    private List<BundleInfo> bundleInfos_;
    private DeviceSpec deviceSpecParams_;
    private boolean mInvalidRequest;
    private String pkgName_;
    private int versionCode_;

    public static class BundleInfo extends JsonBean {
        private String bundleTarget_;
        private String featureValue_;

        private BundleInfo(String str, String str2) {
            this.bundleTarget_ = str;
            this.featureValue_ = str2;
        }
    }

    public static class b {
        private final Set<String> ʼ = new HashSet();
        private final Set<String> ʽ = new HashSet();
        private int ˊ;
        private String ˋ;
        private boolean ˎ;
        private boolean ˏ;
        private final Context ॱ;

        public b(@NonNull Context context) {
            this.ॱ = context;
        }

        public b ˎ(String str) {
            this.ˋ = str;
            return this;
        }

        public b ˊ(int i) {
            this.ˊ = i;
            return this;
        }

        public b ˋ() {
            this.ˎ = true;
            return this;
        }

        public b ˊ() {
            this.ˏ = true;
            return this;
        }

        public b ˋ(String str) {
            if (!TextUtils.isEmpty(str)) {
                this.ʼ.add(str);
            }
            return this;
        }

        public b ॱ(String str) {
            if (!TextUtils.isEmpty(str)) {
                this.ʽ.add(str);
            }
            return this;
        }

        public b ˊ(String str, String str2) {
            if ("feature".equals(str)) {
                ˋ(str2);
            } else if ("language".equals(str)) {
                ॱ(str2);
            }
            return this;
        }

        @NonNull
        public GetApksInfoRequest ॱ() {
            if (TextUtils.isEmpty(this.ˋ)) {
                Logger.e(GetApksInfoRequest.TAG, "mPkgName must not be empty, plz call setPkgName first.");
            }
            GetApksInfoRequest getApksInfoRequest = new GetApksInfoRequest();
            getApksInfoRequest.pkgName_ = this.ˋ;
            getApksInfoRequest.versionCode_ = this.ˊ;
            String[] ˏ = bla.ˏ(this.ॱ, getApksInfoRequest.pkgName_);
            if (this.ˎ) {
                getApksInfoRequest.bundleInfos_.add(new BundleInfo("base", ˏ(bks.ˊ(ˏ, ","))));
            }
            if (!this.ʼ.isEmpty()) {
                List ˏ2 = cge.ˏ(this.ʼ, ˏ);
                getApksInfoRequest.bundleInfos_.add(new BundleInfo("feature", bks.ˏ(ˏ2, ",")));
                getApksInfoRequest.mInvalidRequest = ˏ2.isEmpty();
            }
            if (this.ˏ || !this.ʽ.isEmpty()) {
                getApksInfoRequest.bundleInfos_.add(new BundleInfo("language", ˏ(bks.ˊ(ˏ, ","))));
            }
            boolean z = !this.ˎ && this.ʼ.isEmpty();
            getApksInfoRequest.deviceSpecParams_ = new e(this.ॱ).ˎ(this.ˎ).ॱ(this.ʽ).ˎ(z, ˏ).ॱ();
            if (z) {
                getApksInfoRequest.mInvalidRequest = getApksInfoRequest.deviceSpecParams_.ˋ();
            }
            return getApksInfoRequest;
        }

        private static String ˏ(String str) {
            if (TextUtils.isEmpty(str)) {
                return "*";
            }
            return "*," + str;
        }
    }

    private GetApksInfoRequest() {
        this.bundleInfos_ = new ArrayList();
        this.mInvalidRequest = false;
        setMethod_(APIMETHOD);
    }

    public int ˏ() {
        return this.versionCode_;
    }

    public boolean ॱ() {
        return this.mInvalidRequest;
    }
}
